import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'my_audio_recorder_platform_interface.dart';

/// An implementation of [MyAudioRecorderPlatform] that uses method channels.
class MethodChannelMyAudioRecorder extends MyAudioRecorderPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('my_audio_recorder');

  // TODO 2.实现方法
  @override
  Future<String?> getPlatformVersion() async {
    final version =
        await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  @override
  Future<String?> startRecord() async {
    final res = await methodChannel.invokeMethod<String>('startRecord');
    return res;
  }

  @override
  Future<String?> continueRecord() async {
    final res = await methodChannel.invokeMethod<String>('continueRecord');
    return res;
  }

  @override
  Future<String?> pauseRecord() async {
    final res = await methodChannel.invokeMethod<String>('pauseRecord');
    return res;
  }

  @override
  Future<String?> stopRecord() async {
    final res = await methodChannel.invokeMethod<String>('stopRecord');
    return res;
  }

  @override
  Future<String?> playAudio(String audioPath) async {
    final res =
        await methodChannel.invokeMethod<String>('playAudio', audioPath);
    return res;
  }
}
